home *** CD-ROM | disk | FTP | other *** search
/ Risc World 3 / Risc World 3.iso / SOFTWARE / ISSUE6 / PD / PDF / GuiLib / Task / h / GuiTargets < prev    next >
Text File  |  2003-02-14  |  5KB  |  116 lines

  1. //--------------------------------------------------------------------------
  2. //
  3. //   Copyright (c) 2002, Colin Granville
  4. //
  5. //   All rights reserved.
  6. //
  7. //   Redistribution and use in source and binary forms, with or
  8. //   without modification, are permitted provided that the following 
  9. //   conditions are met:
  10. //
  11. //      * Redistributions of source code must retain the above copyright 
  12. //        notice, this list of conditions and the following disclaimer.
  13. //
  14. //      * Redistributions in binary form must reproduce the above 
  15. //        copyright notice, this list of conditions and the following 
  16. //        disclaimer in the documentation and/or other materials 
  17. //        provided with the distribution.
  18. //
  19. //      * The name Colin Granville may not be used to endorse or promote 
  20. //        products derived from this software without specific prior 
  21. //        written permission.
  22. //
  23. //   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  24. //   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
  25. //   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
  26. //   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
  27. //   COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
  28. //   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
  29. //   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
  30. //   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
  31. //   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
  32. //   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  33. //   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
  34. //   OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. //--------------------------------------------------------------------------
  37.  
  38. #ifndef GuiTargets_h
  39. #define GuiTargets_h
  40.  
  41. #include "GuiRegister.h"
  42.  
  43. #define GUI_DECLARE_EVENT_TARGETS(TYPE)\
  44. \
  45. class GuiNullTarget : public GuiNullEventTarget\
  46. {\
  47.   public:\
  48.     typedef void (TYPE##::* Method)();\
  49.     GuiNullTarget() : object(0),method(0)                 {}\
  50.     GuiNullTarget(TYPE##* ob,Method m,int interval=0)\
  51.       : GuiNullEventTarget(interval),object(ob),method(m) {}\
  52.     virtual void execute()                       {if (method) (object->*method)();}\
  53.     void         setMethod(TYPE##* ob,Method m) {object=ob;method=m;}\
  54.     void         operator()(TYPE##* ob,Method m,unsigned int interval=0)\
  55.                   {setMethod(ob,m);setInterval(interval);}\
  56. \
  57.   private:\
  58.     TYPE##*   object;\
  59.     Method method;\
  60. };\
  61. \
  62. class GuiToolboxTarget : public GuiToolboxEventTarget\
  63. {\
  64.   public:\
  65.     typedef Claim (TYPE##::* Method)(GuiToolboxEvent&,const GuiIdBlock&);\
  66.     GuiToolboxTarget() : object(0),method(0)                     {}\
  67.     GuiToolboxTarget(GuiObject* o,int event_code,TYPE##* ob,Method m)\
  68.       : GuiToolboxEventTarget(o,event_code),object(ob),method(m) {}\
  69.     virtual Claim execute(GuiToolboxEvent& t,const GuiIdBlock& i)\
  70.                          {return (method)?(object->*method)(t,i):DONT_CLAIM;}\
  71.     void          setMethod(TYPE##* ob,Method m) {object=ob;method=m;}\
  72.     void          operator()(const GuiObject* o,int event_code,TYPE##* ob,Method m)\
  73.                   {setListener(o,event_code);setMethod(ob,m);}\
  74. \
  75.   private:\
  76.     TYPE##*   object;\
  77.     Method    method;\
  78. };\
  79. \
  80. class GuiWimpTarget : public GuiWimpEventTarget\
  81. {\
  82.   public:\
  83.     typedef Claim (TYPE##::* Method)(GuiWimpPollBlock&,const GuiIdBlock&);\
  84.     GuiWimpTarget() : object(0),method(0)                     {}\
  85.     GuiWimpTarget(GuiObject* o,int event_code,TYPE##* ob,Method m)\
  86.       : GuiWimpEventTarget(o,event_code),object(ob),method(m) {}\
  87.     virtual Claim execute(GuiWimpPollBlock& wpb,const GuiIdBlock& i)\
  88.                          {return (method)?(object->*method)(wpb,i):DONT_CLAIM;}\
  89.     void          setMethod(TYPE##* ob,Method m) {object=ob;method=m;}\
  90.     void          operator()(const GuiObject* o,int event_code,TYPE##* ob,Method m)\
  91.                   {setListener(o,event_code);setMethod(ob,m);}\
  92. \
  93.   private:\
  94.     TYPE##*   object;\
  95.     Method    method;\
  96. };\
  97. \
  98. class GuiMessageTarget : public GuiMessageEventTarget\
  99. {\
  100.   public:\
  101.     typedef Claim (TYPE##::* Method)(GuiWimpMessage&);\
  102.     GuiMessageTarget() : object(0),method(0)                     {}\
  103.     GuiMessageTarget(int message_code,TYPE##* ob,Method m)\
  104.       : GuiMessageEventTarget(message_code),object(ob),method(m) {}\
  105.     virtual Claim execute(GuiWimpMessage& wm)        {return (method)?(object->*method)(wm):DONT_CLAIM;}\
  106.     void          setMethod(TYPE##* ob,Method m) {object=ob;method=m;}\
  107.     void          operator()(int message_code,TYPE##* ob,Method m)\
  108.                   {setListener(message_code);setMethod(ob,m);}\
  109. \
  110.   private:\
  111.     TYPE##*   object;\
  112.     Method    method;\
  113. }
  114.  
  115. #endif
  116.